package com.sun.j2ee.blueprints.servicelocator.web;

import com.sun.j2ee.blueprints.servicelocator.ServiceLocatorException;
import com.sun.j2ee.blueprints.servicelocator.web.ServiceLocator;

public aspect SingletonAspect issingleton(){

	private static ServiceLocator ServiceLocator.instance;
	
	public static ServiceLocator ServiceLocator.getInstance() {
		return ServiceLocator.instance;
	};
	
	static {
	     try {
	    	 ServiceLocator.instance = new ServiceLocator();
	      } catch(ServiceLocatorException se) {
	        System.err.println(se);
	        se.printStackTrace(System.err);
	      }
	    }

	/*pointcut instanciate(): call(ServiceLocator.new(..)) && !within(SingletonAspect);

	ServiceLocator around() : instanciate() {
		synchronized (this) {
			if (ServiceLocator.instance == null) {
				ServiceLocator.instance = proceed();
			}
		return ServiceLocator.instance;
		}
	};*/

}
